package com.kt.mes.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.kt.mes.domain.WasteStoreList;
import com.kt.mes.service.IWasteStoreListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 废料详情Controller
 * 
 * @author lzc
 * @date 2021-04-19
 */
@RestController
@RequestMapping("/mes/WasteStoreList")
public class WasteStoreListController extends BaseController
{
    @Autowired
    private IWasteStoreListService wasteStoreListService;

    /**
     * 查询废料详情列表
     */
    @PreAuthorize("@ss.hasPermi('mes:WasteStoreList:list')")
    @GetMapping("/list")
    public TableDataInfo list(WasteStoreList wasteStoreList)
    {
        startPage();
        List<WasteStoreList> list = wasteStoreListService.selectWasteStoreListList(wasteStoreList);
        return getDataTable(list);
    }

    /**
     * 导出废料详情列表
     */
    @PreAuthorize("@ss.hasPermi('mes:WasteStoreList:export')")
    @Log(title = "废料详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WasteStoreList wasteStoreList)
    {
        List<WasteStoreList> list = wasteStoreListService.selectWasteStoreListList(wasteStoreList);
        ExcelUtil<WasteStoreList> util = new ExcelUtil<WasteStoreList>(WasteStoreList.class);
        return util.exportExcel(list, "WasteStoreList");
    }

    /**
     * 获取废料详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:WasteStoreList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wasteStoreListService.selectWasteStoreListById(id));
    }

    /**
     * 新增废料详情
     */
    @PreAuthorize("@ss.hasPermi('mes:WasteStoreList:add')")
    @Log(title = "废料详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WasteStoreList wasteStoreList)
    {
        return toAjax(wasteStoreListService.insertWasteStoreList(wasteStoreList));
    }

    /**
     * 修改废料详情
     */
    @PreAuthorize("@ss.hasPermi('mes:WasteStoreList:edit')")
    @Log(title = "废料详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WasteStoreList wasteStoreList)
    {
        return toAjax(wasteStoreListService.updateWasteStoreList(wasteStoreList));
    }

    /**
     * 删除废料详情
     */
    @PreAuthorize("@ss.hasPermi('mes:WasteStoreList:remove')")
    @Log(title = "废料详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wasteStoreListService.deleteWasteStoreListByIds(ids));
    }
}
